package com.xbongbong.saas.enums.dictionary;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * 数据字典-订货单下单类型
 * @author wujian
 * @version v1.0
 * @date 2021/01/04 10:19
 * @since v1.0
 */
@Getter
public enum OrderTypeEnum {
    //代客下单 自主下单
    VALET_ORDER("1","enum.orderType.name.valet_order","valetOrder","enum.orderType.mallName.valet_order"),
    INDEPENDENT_ORDER("2","enum.orderType.name.independent_order","independentOrder","enum.orderType.mallName.independent_order")
            ;
    private String code;
    private String name;
    private String attr;
    private String mallName;

    OrderTypeEnum(String code, String name, String attr, String mallName) {
        this.code = code;
        this.name = name;
        this.attr = attr;
        this.mallName = mallName;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }
    public String getMallName() {
        return I18nMessageUtil.getMessage(mallName);
    }

    public static String getByCode(String code) {
        for (OrderTypeEnum typeEnum : OrderTypeEnum.values()) {
            if (Objects.equals(typeEnum, code)) {
                return typeEnum.getName();
            }
        }
        return "";
    }

    public static String getHelpMark(String code) {
        if (Objects.equals(code, OrderTypeEnum.VALET_ORDER.getCode())) {
            return OrderTypeEnum.VALET_ORDER.getMallName();
        }
        return "";
    }
}
